package com.company.thread;

import cn.hutool.json.JSONUtil;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2020/10/21 17:15
 */
public class MyThread2 {

    public static void main(String[] args) {
        SelfThread t = new SelfThread();
        SelfThread t2= new SelfThread();
        t.setName("T1");
        t2.setName("T2");
        t.start();
        t2.start();


        try {
            t.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        System.out.println(Thread.currentThread().getName()+": "+"end...");
    }



}

class SelfThread extends Thread {
    int i = 5;
    @Override
    public void run() {
        while (i > 0) {
            System.out.println(Thread.currentThread().getName()+": "+"i:"+ i--);
            if ("T1".equals(Thread.currentThread().getName())) {
                return;
            }
            try {
                Thread.sleep(400);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
